<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<view class="" @click="toAuth">
			授权
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},

		onLoad(o) {
			console.log("o:", o);
			// const code = this.getUrlParam('code');
			// console.log('code：', code);
			const appid = 'wx417ec4d67b687e37';
			if (!o.code) {
				console.log(window.location.href);
				// const redirectUri = encodeURIComponent(window.location.href);
				const redirectUri = encodeURIComponent("http://h5.wangjinsheng.cloud");
				const url = `http://mp.wangjinsheng.cloud/wx/mp/oauth2?url=${redirectUri}`;
				console.log("url:",url);
				window.location.href = url;
				// window.open(url)
				// uni.request({
				// 	url:url
				// }).then(() => )
				// 	console.log(redirectUri);
			} else {
				// uni.request({
				// 	url: `http://localhost:10000/wx/redirect/${appid}/auth?code=${o.code}`,
				// }).then(resp =>{
				// 	console.log(resp);
				// })
			}
		},
		methods: {
			getAuthCodeUrl() {
				// const url =
				// 	`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=ok#wechat_redirect`;
			},
			toAuth() {
				// uni.request({
				// 	url: 'http://localhost:10000/wx/redirect/wx7a1ad28f8c6f70e7/greet&code='
				// }).then(resp => {
				// 	console.log(resp);
				// })

			},
			log() {
				console.log(1111111);
			},
			// 从 URL 参数中提取 code
			getUrlParam(name) {
				// const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`);
				// const r = window.location.search.substr(1).match(reg);
				// return r ? decodeURIComponent(r‌: ml - citation {
				// 	ref = "6"
				// 	data = "citationList"
				// }) : null;
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>